package com.model.defaults.tabsheet.entities;

import java.util.Map;

import org.hibernate.Session;

import com.core.utils.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;



public class ModelDefaultTabsheetTask {

	public static void createTabsheetItemsTaskOpen ( Session session,
	                                                 Map <String, UserContextName> userContexts ) {

		/*
		 * OpenProject
		 */

		TabSheetItem pojo = null;
		UserContextName visibleInContextName_1 = null;
		UserContextName userContextNameToExecute = null;


		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;

		/*
		 * OpenTask
		 */



		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("t1", "selectedTab=1");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("p1", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p1}&{t1}", GlobalConstants.SERVLET_TASKINFO);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);

		pojo = new TabSheetItem();
		pojo.setName("tabsheet.taskitem.description");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/ProjectTaskDescription.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_TASKINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);


		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("t1", "selectedTab=2");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("p1", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p1}&{t1}", GlobalConstants.SERVLET_TASKINFO);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_SUBTASKSLIST);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.taskitem.issues");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/tabTaskTaskList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_TASKINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}


}
